﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GatewayInspect.Common;
using System.Data.OracleClient;

namespace GatewayInspect.Modules
{
    public partial class InOutGateCLTJModule : BaseModule
    {
        public InOutGateCLTJModule()
        {
            InitializeComponent();
        }

        protected override void OnInitialize()
        {
            base.OnInitialize();
            foreach (ToolStripItem item in this.tsMain.Items)
            {
                if (item != tsBtnRefresh && item != tsBtnClose && item != toolStripSeparator3)
                {
                    item.Visible = false;
                }
            }
        }

        protected override void OnInit()
        {
            base.OnInit();
            dtpEnd.Value = DateTime.Now;
            dtpBegin.Value = DateTime.Now.Date;
        }

        protected override void OnLoadModule()
        {
            base.OnLoadModule();

            string strSql = "select count(*) from IN_OUT_GATE where ORGCODE = '" + Session.CurrentOrgCode + "' and IN_DATE>=:beginTime and IN_DATE<=:endTime";
            DataTable dt = DataAccess.ExecuteDataTable(strSql, new OracleParameter(":beginTime", dtpBegin.Value), new OracleParameter(":endTime", dtpEnd.Value));
            if (dt != null && dt.Rows.Count > 0)
            {
                this.lblJCS.Text = dt.Rows[0][0].ToString();
            }
            strSql = "select count(*) from IN_OUT_GATE where ORGCODE = '" + Session.CurrentOrgCode + "' and IN_OUT_BS='2' and OUT_DATE>=:beginTime and OUT_DATE<=:endTime";
            dt = DataAccess.ExecuteDataTable(strSql, new OracleParameter(":beginTime", dtpBegin.Value), new OracleParameter(":endTime", dtpEnd.Value));
            if (dt != null && dt.Rows.Count > 0)
            {
                this.lblCCS.Text = dt.Rows[0][0].ToString();
            }
            strSql = "select count(*) from IN_OUT_GATE where ORGCODE = '" + Session.CurrentOrgCode + "' and IN_OUT_BS='1'";
            dt = DataAccess.ExecuteDataTable(strSql);
            if (dt != null && dt.Rows.Count > 0)
            {
                this.lblZCS.Text = dt.Rows[0][0].ToString();
            }
        }

        private void btnQuery_Click(object sender, EventArgs e)
        {
            OnLoadModule();
        }
    }
}
